package br.inatel.ec203.projeto.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

public class ButtonPanel extends JPanel {

	private static final long serialVersionUID = -148553094512482523L;
	
	private JButton okButton;
	private ButtonPanelListeners okPanelListeners;

	public ButtonPanel() {
		initialize();
	}

	private void initialize() {
		add(getOkButton());
	}
	
	private JButton getOkButton() {
		if (okButton == null) {
			okButton = new JButton();
			okButton.setText("OK");
			okButton.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					okPanelListeners.okPerformed();
				}
			});
		}
		return okButton;
	}
	
	public void addOkPanelListeners(ButtonPanelListeners okPanelListeners) {
		this.okPanelListeners = okPanelListeners;
	}
}
